package view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import view.interfaces.IEditShape;
import view.interfaces.IProposition;
import model.MyShape;
import controller.ControllerEditShape;
import controller.ControllerHome;
import controller.ControllerProposition;

public class Proposition extends JFrame implements IProposition{
	
	private ControllerProposition thisController;
	private static final long serialVersionUID = 1L;
	public int shapeToEditId;
	public MyShape shapeToEdit;
	
	private JFrame jFrame;
    private JButton btnEditShape;
    private JButton btnReverse;
    
	public Proposition(int shape, int x, int y) {
	
		super("");
		this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		thisController = new ControllerProposition();
	    thisController.setView(this);
	    
	    shapeToEditId = shape;
		shapeToEdit = ControllerHome.image.getShape(shape);
	
		System.out.println("Ouverture modif forme :"+shape);
		
		jFrame = new JFrame();
	    jFrame.getContentPane().setLayout(new GridLayout(2,1));
	    
	    btnEditShape = new JButton("Modifier");
	    btnEditShape.addActionListener(thisController);
	    btnEditShape.setActionCommand("EDITSHAPE");
	    
	    btnReverse = new JButton("Echanger couleurs");
	    btnReverse.addActionListener(thisController);
	    btnReverse.setActionCommand("REVERSE");
	    
	    this.getContentPane().add(btnEditShape, BorderLayout.NORTH);
	    this.getContentPane().add(btnReverse, BorderLayout.SOUTH);
	    
	    this.setSize(200,100);
	    
	    this.setLocation(x+20,y+60);
	    
	    this.setVisible(true);
	    
	}
	
	public void hideWindowEditShape() {
		
		this.setVisible(false);
		
	}

	public MyShape getShapeToEdit() {
		
		return shapeToEdit;

	}
	
	public int getShapeToEditId() {
		
		return shapeToEditId;
		
	}


}
